package com.hex.ds.hdrs.agent.dao;

import com.hex.bigdata.hbda.base.BaseDao;
import com.hex.bigdata.hbda.base.Page;
import com.hex.ds.hdrs.agent.po.AgentConf;
import com.hex.ds.hdrs.app.vo.AppAgentVo;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class AgentConfDao extends BaseDao {

    public int add(AgentConf agentConf) {
        return this.insert("com.hex.ds.hdrs.agent.dao.AgentConfDao.insert", agentConf);
    }

    public int deleteById(String id) {
        return this.delete("com.hex.ds.hdrs.agent.dao.AgentConfDao.deleteById", id);
    }

    public int update(Map map) {
        return this.update("com.hex.ds.hdrs.agent.dao.AgentConfDao.updateById", map);
    }

    public int updateAgentStatus(Map<String, String> map) {
        return this.update("com.hex.ds.hdrs.agent.dao.AgentConfDao.updateAgentByCode", map);
    }
    public int updateAgentLstTime(Map<String, String> map) {
        return this.update("com.hex.ds.hdrs.agent.dao.AgentConfDao.updateAgentLstTime", map);
    }

    public List<AgentConf> qryAgentList(Map map) {
        return this.selectList(AgentConf.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryAgentConf", map);
    }

    public List<AgentConf> qryAgentPage(Map map, Page page) {
        return this.selectPage(AgentConf.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryAgentConf", page, map);
    }

    public List<AgentConf> qryAgentList() {
        return this.selectList(AgentConf.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryAgentConf");
    }

    public AgentConf qryAgentConf(Map map) {
        return this.selectOne(AgentConf.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryAgentConf", map);
    }

    public int checkRepeatCode(String agentCode) {
        return this.selectOne(Integer.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.checkRepeatCode", agentCode);
    }

    public List<String> selectCodes() {
        return this.selectList(String.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.selectCodes");
    }

    public List<AppAgentVo> qryNodeByUser(String username) {
        return this.selectList(AppAgentVo.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryNodeByUser", username);
    }

    public List<String> qryAgentCodeByUser(String username) {
        return this.selectList(String.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryAgentCodeByUser", username);
    }

    public List<AppAgentVo> qryNodeByCurrentApp(String appCode) {
        return this.selectList(AppAgentVo.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryNodeByCurrentApp",appCode);
    }

    public List<AgentConf> qryAgentConfList(Map map) {
        return this.selectList(AgentConf.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryAgentConfByAppCode", map);
    }

    public Integer checkAgentName(String agentName) {
        return this.selectOne(Integer.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.checkAgentName", agentName);
    }

    public Integer qryAgentCount() {
        return this.selectOne(Integer.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryAgentCount", null);
    }

    public Integer checkAgentIP(String agentIp) {
      return  this.selectOne(Integer.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.checkAgentIp", agentIp);
    }

    public int qryConcurrentNum(){
        return this.selectOne(Integer.class, "com.hex.ds.hdrs.agent.dao.AgentConfDao.qryConcurrentNum", null);
    }

    public int updateAgentByCode(Map<String, String> map) {
        return this.update("com.hex.ds.hdrs.agent.dao.AgentConfDao.updateAgentByCode", map);
    }

}